package com.tomek.ktoryoperator.providers;

import java.util.Arrays;
import java.util.HashSet;

import android.content.Context;

import com.tomek.ktoryoperator.R;

public class PolishLandlineNumberInfoProvider extends AbstractPolishNumberInfoProvider {
	private static final String[] LANDLINE_PREFIXES = new String[] { "12", "13", "14", "15", "16", "17", "18", "22",
			"23", "24", "25", "29", "32", "33", "34", "41", "42", "43", "44", "46", "48", "52", "54", "55", "56", "58",
			"59", "61", "63", "63", "65", "67", "68", "71", "74", "75", "76", "77", "81", "82", "83", "84", "85", "86",
			"87", "89", "91", "94", "95", };

	private static final HashSet<String> LANDLINE_PREFIXES_SET = new HashSet<String>(Arrays.asList(LANDLINE_PREFIXES));

	private static final String LANDLINE_ID = "LANDLINE";

	@Override
	public String getNumberInfoId(String number) {
		String directionNumber = number.substring(2, 4);

		if (LANDLINE_PREFIXES_SET.contains(directionNumber)) {
			return LANDLINE_ID;
		} else {
			return null;
		}
	}

	@Override
	public int getImageResourceForNumber(String value) {
		if (LANDLINE_ID.equals(value)) {
			return R.drawable.ic_phone;
		} else {
			return super.getImageResourceForNumber(value);
		}
	}

	@Override
	public String getNumberInfoName(Context context, String numberInfoId) {
		return context.getString(R.string.LANDLINE);
	}

	@Override
	public String getProviderName(Context context) {
		return context.getString(R.string.LANDLINE_PROVIDER);
	}
}